package com.ryan.spring.annotation.ext;

import com.ryan.spring.annotation.model.Car;
import com.ryan.spring.annotation.model.Person;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

/**
 * Created by kaimin on 14/2/2019.
 * time : 22:19
 */
@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("MyBeanFactoryPostProcessor");
        BeanDefinition person = beanFactory.getBeanDefinition("person");
        if (person instanceof Person) {
            ((Person) person).setName("ppp");
        }
    }
}
